//
//  AddressViewController.m
//  AXF
//
//  Created by Stone丶熊小叔 on 2017/1/4.
//  Copyright © 2017年 zw. All rights reserved.
//

#import "AddressViewController.h"
#import "AddressTableViewController.h"
#import <Masonry.h>
#import "AddressDetailTableViewController.h"
@interface AddressViewController ()

@end

@implementation AddressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的收货地址";
    
    //收货地址控制器
    AddressTableViewController *tabVC = [[AddressTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
    [self addChildViewController:tabVC];
    [self.view addSubview:tabVC.view];
    [tabVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.bottom.offset(-60);
    }];
    //尾部视图
    UIView *footView = [[UIView alloc] init];
    footView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:footView];
    [footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.equalTo(tabVC.view.mas_bottom);
    }];
    UIImageView *imgV = [[UIImageView alloc] init];
    imgV.image = [UIImage imageNamed:@"icon_sendcoupon"];
    [footView addSubview:imgV];
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.equalTo(footView);
    }];
    
    UIButton *btn = [[UIButton alloc] init];
    [btn setTitle:@"+新增地址" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn setTitle:@"+新增地址" forState:UIControlStateHighlighted];
    [btn setTitleColor:[UIColor cyanColor] forState:UIControlStateHighlighted];
    [footView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.equalTo(imgV);
    }];
    [btn addTarget:self action:@selector(addNewAddress:) forControlEvents:UIControlEventTouchUpInside];
};


///添加地址
-(void)addNewAddress:(UIButton *)btn
{
    AddressDetailTableViewController *detailVC = [[AddressDetailTableViewController alloc] init];
    [self.navigationController pushViewController:detailVC animated:NO];
    NSLog(@"新增地址");
}
     
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
